package br.mg.bhe.ftpobre.command;

import br.mg.bhe.ftpobre.Main;
import br.mg.bhe.ftpobre.gui.MainFrame;
import br.mg.bhe.ftpobre.gui.fs.FileTableModelBuilder;

/**
 * 
 * @author Aureliano
 */
public class RefreshRemoteFilesViewCommand implements ICommand {

    @Override
    public void execute() {
        if (this.canExecute()) {
            this.doAction();
        }
    }

    @Override
    public boolean canExecute() {
        return Main.getConnectionData().isConnected();
    }

    private void doAction() {
        String path = MainFrame.getInstance().getAbsolutePathFromRemoteFilePath();
	MainFrame.getInstance().getTableRemoteFiles().setModel(
                FileTableModelBuilder.createRemoteFilesTableModel(path));
    }
}